<template>
  <div class="header-container border-bottom">
    <div class="header-center">
      <div class="center">
        <input type="text" placeholder="请输入关键字" v-model="keyWord"/>
      </div>
      <div class="right">
        <span class="iconfont">&#xe62d;</span>
      </div>
    </div>
    <div class="header-right" @click="goCart">
      <img src="~assets/images/home/cart-right.png" alt="" />
    </div>
  </div>
</template>

<script>
import { getSearchData } from 'network/search'
export default {
  name: "Header",
  data () {
    return {
      keyWord: 'ss',
      deviceList: [], // 调用接口获取的全部数据
      resultList: [], //真正展示的数据，也就是筛选后的数据
    }
  },
  created () {
    this.getSearchData();
  },
  methods: {
    goCart () {
      this.$router.push('/cart')
    },
    /* w网络请求相关的方法 */
    getSearchData() {
      getSearchData().then((res) => {
        this.deviceList = res.result;
        // console.log(this.deviceList);
      })
    }
  }
};
</script>

<style lang="less" scoped>
.header-container {
  position: fixed;
  display: flex;
  height: 0.44rem;
  line-height: 0.44rem;
  background: #fff;
  left: 0;
  right: 0;
  top: 0;
  z-index: 9;
  .header-center {
    width: 3rem;
    height: 0.3rem;
    display: flex;
    line-height: 0.3rem;
    margin-top: 0.07rem;
    align-content: center;
    margin-left: 0.15rem;
    border: 1px solid #ccc;
    border-radius: 0.15rem;
    .center {
      input {
        width: 1rem;
        height: 0.15rem;
        font-size: 0.12rem;
        margin-left: 0.14rem;
        color: #999;
      }
    }
  }
  .right {
    span {
      display: inline-block;
      width: 0.2rem;
      height: 0.19rem;
      margin-left: 1.5rem;
    }
  }
  .header-right {
    float: right;
    margin-left: 0.25rem;
    img {
      display: inline-block;
      width: 0.2rem;
      height: 0.19rem;
    }
  }
}
</style>
